<?php
    /* Immanuel192 write this action on 8/12/2009 */
    global $db;
    // Used later, for recalculation and other things.
    if (!defined("SYS_SORTING")) require_once(BASE."subsystems/sorting.php");

    // get module title
    // because if the client switch page, so, that is the action and exponent does not transfer $title and $views
    $temp=$db->selectObject("container","internal = '" . serialize($loc) . "'");
    if ($temp)
    {
        $title=$temp->title;
        $view=$temp->view;
    }
    else
    {
        $title="";
        $view="Default";
    }
    // Create the template
    $template = new template("bbwidgetmodule",$view,$loc);

    $config->items=25;
    
    // 8/14/2009: Immanuel192 write this code to spilt page
    $temp=$db->selectObjects("bb_post"," 1 ORDER BY posted DESC, id ASC limit 0,{$config->items}"); 
    foreach ($temp as $k=>$v) {
        $v->create_date = _ab_dateFormat($v->posted,0);
        
        // get user name
        $tuser=exponent_users_getUserById($v->poster);
        $v->poster_name = $tuser->username;
    }
    $data[0]=$temp;

    $template->assign('data',$data); 
    $template->register_permissions(
        array('administrate','configure','manage'),
    $loc);
    $template->assign('moduletitle', $title);
    if (!(isset($_REQUEST['flow_has_set']) && ($_REQUEST['flow_has_set']==1)))
        exponent_flow_set(SYS_FLOW_PUBLIC,SYS_FLOW_ACTION);
    $template->output();
?>
